<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('发货单明细列表')" />
</head>
<body class="gray-bg">
     <input type="hidden" id="billNo" name="billNo" th:value="${param.billNo}"/>
     <div class="container-div">
        <div class="row">
            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()">
                    <i class="fa fa-search"></i>刷新
                </a>
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="goods:billHead:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="goods:billHead:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="goods:billHead:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
<!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="goods:billHead:export">-->
<!--                    <i class="fa fa-download"></i> 导出-->
<!--                </a>-->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table" data-show-print="true"></table>
            </div>
        </div>
    </div>
     <th:block th:include="include :: footer" />
     <th:block th:include="include :: bootstrap-table-print-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('goods:billHead:edit')}]];
        var removeFlag = [[${@permission.hasPermi('goods:billHead:remove')}]];
        var prefix = ctx + "goods/billHead";
        var prefixDownload=ctx + "common/download/resource?resource=";
        $(function() {
            var billNo=$("#billNo").val();
            var options = {
                url: prefix + "/list?billNo="+billNo,
                createUrl: prefix + "/add?billNo="+billNo,
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                printPageBuilder: printPageBuilder,
                modalName: "发货单明细",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'billNo',
                    title: '单号'
                },
                {
                    field: 'styleNumber',
                    title: '款号'
                },
                {
                    field: 'imgPath',
                    title: '图片',
                    formatter: function(value, row, index) {
                        //console.log(row.imgPath)
                        if(row.imgPath==''||row.imgPath==null){
                            return '';
                        }else{
                            return $.table.imageView(prefixDownload+row.imgPath);
                        }
                    }
                },
                {
                    field: 'quantity',
                    title: '数量'
                },
                {
                    field: 'price',
                    title: '单价'
                },
                {
                    field: 'totalPrice',
                    title: '总价'
                }//,
                // {
                //     title: '操作',
                //     align: 'center',
                //     formatter: function(value, row, index) {
                //         var actions = [];
                //         //actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.billHeadId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                //         //actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.billHeadId + '\')"><i class="fa fa-remove"></i>删除</a>');
                //         return actions.join('');
                //     }
                // }
                ]
            };
            $.table.init(options);
        });

        // 自定义打印页面模板
        function printPageBuilder(table) {
            return `
        	<html>
        	  <head>
        	  <style type="text/css" media="print">
        	  @page {
        	    size: auto;
        	    margin: 25px 0 25px 0;
        	  }
        	  </style>
        	  <style type="text/css" media="all">
        	  table {
        	    border-collapse: collapse;
        	    font-size: 12px;
        	  }
        	  table, th, td {
        	    border: 1px solid grey;
        	  }
        	  th, td {
        	    text-align: center;
        	    vertical-align: middle;
        	  }
        	  p {
        	    font-weight: bold;
        	    margin-left:20px;
        	  }
        	  table {
        	    width:94%;
        	    margin-left:3%;
        	    margin-right:3%;
        	  }
        	  div.bs-table-print {
        	    text-align:center;
        	  }
        	  </style>
        	  </head>
        	  <title>Print Table</title>
        	  <body>
        	  1111111
        	  <div class="bs-table-print">${table}</div>
        	  </body>
        	</html>`
        }

    </script>
</body>
</html>